var HomePage = Objs("view.components.HomePage",
	UiComponent,
{  
	userProfile:null,
	doRestore:null,
	dashBoard:null,
	newSubmission:null,
	bidAccepted:null,
	inPossession:null,
	allVehicle:null,
	addNewVehicle:null,
	vehicleList:null,
	vehicleMap:null,
	vehicleRefresh:null,
	cancelInfo:null,
	saveInfo:null,
	lockedVehicles:null,
	listmap:null,
	vIdSort:null,
	vYearSort:null,
	vMakeSort:null,
	vModelSort:null,
	vSellerSort:null,
	vCityStateSort:null,
	vUpdatedSort:null,
	vPriceSort:null,
	vAssistSort:null,
	vActionSort:null,
	vIconsSort:null,
	searchBtn:null,
	////Tower admin
	taNewSubmissionCmp:null,     
    taProgressVehicleCmp:null,   
    taDeliveredVehicleCmp:null,    
    taAllVehicleCmp:null,          
	////Tower admin
	
	initialize: function()
	{  
		HomePage.$super.initialize.call( this );
		this.initializeChildren();
		this.bindListeners();
             
                 this.initializePage();
	},
        initializePage:function()
        {
       
          
            
        },
	
    initializeChildren: function()
    {           
                this.dashBoard = jQuery("#dash-board");
		this.userProfile = jQuery("#userProfile");
		this.doRestore = jQuery("#archiveRestore");
		//this.dashBoard = jQuery("#dashboard");
		this.newSubmission = jQuery("#ns-li");
                this.newSubmissionCmp = jQuery("#new-vehicle-component");
		this.bidAccepted = jQuery("#ba-li");
                this.bidAcceptedCmp = jQuery("#bidaccepted-vehicle-component");
		this.inPossession = jQuery("#nip-li");
                this.inPossessionCmp = jQuery("#inpossesion-vehicle-component");
		this.allVehicle = jQuery("#av-li");
                this.allVehicleCmp = jQuery("#all-vehicle-component");
		this.addNewVehicle = jQuery("#add-new");
                this.addNewVehicleBtm = jQuery("#addnew_bottom");
                this.addNewVehicleTop = jQuery("#addnew_top");
				
		///////////////////////////START:Tabs for Tower Administrators//////////////////////////										
        this.taNewVehicleCmp = jQuery("#ta-new-vehicle-component");
        this.taProgressVehicleCmp = jQuery("#ta-progress-vehicle-component");
        this.taDeliveredVehicleCmp = jQuery("#ta-delivered-vehicle-component");
        this.taAllVehicleCmp = jQuery("#ta-all-vehicle-component");
		///////////////////////////END:Tabs for Tower Administrators//////////////////////////
                
         ///////////////////////////START: HeaderMenu Tower vehicle list//////////////////////////	       
           this.towernewvehicles = jQuery("#tnv-li");
           this.towerinprogressvehicles = jQuery("#tip-li");
           this.towerdeliveredvehicles = jQuery("#tdl-li");
           this.towerallvehicles = jQuery("#tall-li");	
      ///////////////////////////END:Tabs for Tower Administrators//////////////////////////     
           
		
		this.vehicleList = jQuery("#vehicle-list");
		this.vehicleMap = jQuery("#map-list_button");
                this.vehicleListBtn = jQuery("#vehicle-list_button");
		this.vehicleRefresh = jQuery("#refresh_button");
		this.lockedVehicles = jQuery("#locked_vehicle");
	
		this.vIdSort = jQuery("#v-id-sort");
		this.vYearSort = jQuery("#v-year-sort");
		this.vMakeSort = jQuery("#v-make-sort");
		this.vModelSort = jQuery("#v-model-sort");
		this.vSellerSort= jQuery("#v-seller-sort");
		this.vCityStateSort = jQuery("#v-city-state-sort");
		this.vUpdatedSort= jQuery("#v-updated-sort");
		this.vPriceSort= jQuery("#v-price-sort");
		this.vAssistSort = jQuery("#v-assist-sort");
		this.vActionSort= jQuery("#v-action-sort");
		this.vIconsSort = jQuery("#v-icons-sort");
		this.searchBtn = jQuery("#searchSubmit");
                this.refreshBtn = jQuery("#btn_refresh");
               
    },


	bindListeners: function()
	{   
            
       
        var namespace = ".HomePage";
                this.dashBoard.on("click"+namespace, jQuery.proxy( this, "dashBoard_clickHandler"));
		this.userProfile.on( "click"+namespace, jQuery.proxy( this, "userProfile_clickHandler" ) );
		this.doRestore.on( "click"+namespace, jQuery.proxy( this, "doRestore_clickHandler" ) );
		//this.dashBoard.on( "click"+namespace, jQuery.proxy( this, "dashBoard_clickHandler" ) );
		this.newSubmission.on( "click"+namespace, jQuery.proxy( this, "newSubmission_clickHandler" ) );
                this.newSubmissionCmp.on( "click"+namespace, jQuery.proxy( this, "newSubmission_clickHandler" ) );
		this.bidAccepted.on( "click"+namespace, jQuery.proxy( this, "bidAccepted_clickHandler" ) );
                this.bidAcceptedCmp.on( "click"+namespace, jQuery.proxy( this, "bidAccepted_clickHandler" ) );
		this.inPossession.on( "click"+namespace, jQuery.proxy( this, "inPossession_clickHandler" ) );
                this.inPossessionCmp.on( "click"+namespace, jQuery.proxy( this, "inPossession_clickHandler" ) );
		this.allVehicle.on( "click"+namespace, jQuery.proxy( this, "allVehicle_clickHandler" ) );
                this.allVehicleCmp.on( "click"+namespace, jQuery.proxy( this, "allVehicle_clickHandler" ) );
		this.addNewVehicle.on( "click"+namespace, jQuery.proxy( this, "addNewVehicle_clickHandler" ) );
                this.addNewVehicleBtm.on( "click"+namespace, jQuery.proxy( this, "addNewVehicle_clickHandler" ) );
                this.addNewVehicleTop.on( "click"+namespace, jQuery.proxy( this, "addNewVehicle_clickHandler" ) );
				
		//START:Tower Administrator click handlers 
		this.taNewVehicleCmp.on( "click"+namespace, jQuery.proxy( this, "ta_new_vehicle_clickHandler" ) );
		this.taProgressVehicleCmp.on( "click"+namespace, jQuery.proxy( this, "ta_progress_clickHandler" ) );
		this.taDeliveredVehicleCmp.on( "click"+namespace, jQuery.proxy( this, "ta_delivered_clickHandler" ) );
		this.taAllVehicleCmp.on( "click"+namespace, jQuery.proxy( this, "ta_all_vehicle_clickHandler" ) );
		//END:Tower Administrator click handlers
                
                //START:Tower Header menu vehicle list 
                 this.towernewvehicles.on( "click"+namespace, jQuery.proxy( this, "towernewvehicles_clickHandler" ) );
                this.towerinprogressvehicles.on( "click"+namespace, jQuery.proxy( this, "towerinprogressvehicles_clickHandler" ) );
                this.towerdeliveredvehicles.on( "click"+namespace, jQuery.proxy( this, "towerdeliveredvehicles_clickHandler" ) );
                this.towerallvehicles.on( "click"+namespace, jQuery.proxy( this, "towerallvehicles_clickHandler" ) );
                //END:
		
		this.vehicleList.on( "click"+namespace, jQuery.proxy( this, "vehicleList_clickHandler" ) );
		this.vehicleMap.on( "click"+namespace, jQuery.proxy( this, "vehicleMap_clickHandler" ) );
                this.vehicleListBtn.on( "click"+namespace, jQuery.proxy( this, "vehicleListArea_clickHandler" ));
		this.vehicleRefresh.on( "click"+namespace, jQuery.proxy( this, "vehicleRefresh_clickHandler" ) );
		this.lockedVehicles.on( "click"+namespace, jQuery.proxy( this, "lockedVehicles_clickHandler" ) );
	
		this.vIdSort.on( "click"+namespace, jQuery.proxy( this, "vIdSort_clickHandler" ) );
		this.vYearSort.on( "click"+namespace, jQuery.proxy( this, "vYearSort_clickHandler" ) );
		this.vMakeSort.on( "click"+namespace, jQuery.proxy( this, "vMakeSort_clickHandler" ) );
		this.vModelSort.on( "click"+namespace, jQuery.proxy( this, "vModelSort_clickHandler" ) );
		this.vSellerSort.on( "click"+namespace, jQuery.proxy( this, "vSellerSort_clickHandler" ) );
		this.vCityStateSort.on( "click"+namespace, jQuery.proxy( this, "vCityStateSort_clickHandler" ) );
		this.vUpdatedSort.on( "click"+namespace, jQuery.proxy( this, "vUpdatedSort_clickHandler" ) );
		this.vPriceSort.on( "click"+namespace, jQuery.proxy( this, "vPriceSort_clickHandler" ) );
		this.vAssistSort.on( "click"+namespace, jQuery.proxy( this, "vAssistSort_clickHandler" ) );
		this.vActionSort.on( "click"+namespace, jQuery.proxy( this, "vActionSort_clickHandler" ) );
		this.vIconsSort.on( "click"+namespace, jQuery.proxy( this, "vIconsSort_clickHandler" ) );
		this.searchBtn.on( "click"+namespace, jQuery.proxy( this, "searchBtn_clickHandler" ) );
                this.refreshBtn.on( "click"+namespace, jQuery.proxy( this, "refreshBtn_clickHandler" ) );
	},
	/*******/
        dashBoard_clickHandler: function()
        {     
            // $("#content").children().hide();
            //$("#vehicle-list-page").hide();
            // $("#vehicle-content-info").hide();
            //$("#dash-board-component").show();
           
           window.location='index.php'; 
          
        },
        
        refreshBtn_clickHandler: function()
        {
            $("select#c").val(0);
            $("#s").val('');
            this.dispatchEvent( HomePage.SEARCH );
        },
        
	searchBtn_clickHandler: function()
	{ 
		$("#pagePanel").hide();
		if($("select#c").val() != 0){
			this.dispatchEvent( HomePage.SEARCH );
		}else{
			alert('Please select any search criteria');
			$("#pagePanel").show();
			return;
		}
		
		if(document.getElementById('s').value != ''){
			this.dispatchEvent( HomePage.SEARCH );
		}else{
			alert('Search content not specified');
			$("#pagePanel").show();
		}
	},
	vIdSort_clickHandler: function()
	{ 
		this.dispatchEvent( HomePage.SORT_VID );
	},
	vYearSort_clickHandler: function()
	{ 
		this.dispatchEvent( HomePage.SORT_YEAR );
		
	},
	vMakeSort_clickHandler: function()
	{ 
	    this.dispatchEvent( HomePage.SORT_MAKE );
		
	},
	vModelSort_clickHandler: function()
	{ 
	    this.dispatchEvent( HomePage.SORT_MODEL );
		
	},
	vSellerSort_clickHandler: function()
	{ 
	    this.dispatchEvent( HomePage.SORT_SELER );
		
	},
	vCityStateSort_clickHandler: function()
	{ 
	   this.dispatchEvent( HomePage.SORT_CITY_STATE );
		
	},
	vUpdatedSort_clickHandler: function()
	{ 
	   this.dispatchEvent( HomePage.SORT_UPDATE_DATE );
		
	},
	vPriceSort_clickHandler: function()
	{ 
	   this.dispatchEvent( HomePage.SORT_PRICE );
		
	},
	vAssistSort_clickHandler: function()
	{ 
	    this.dispatchEvent( HomePage.SORT_ASSIST_BY );
		
	},
	vActionSort_clickHandler: function()
	{ 
	    this.dispatchEvent( HomePage.SORT_ACTION );
		
	},
	vIconsSort_clickHandler: function()
	{ 
	   this.dispatchEvent( HomePage.SORT_WATCHLIST );
	},
	/*******/
	userProfile_clickHandler: function()
	{ 
	    alert("SFS");
	},
	lockedVehicles_clickHandler: function()
	{ 
		$('div.page-list').hide();
		$('div.page-map').hide();
		$('div.locked-content').show();
		$('div.forum-content').hide();
		$('#v-control-panel').hide();
	    this.dispatchEvent( HomePage.LOCKED_VEHICLE );
	},
	doRestore_clickHandler: function()
	{ 
	    alert("SFS");
	},
/*	dashBoard_clickHandler: function()
	{ 
	    alert("SFS");
	},*/
         setVehicle_List: function()
        {
               $("#vehicle-list-page").show();
               $("#vehicle-list-area").show();
               $("#vehicle-list-component").show();
               $("#page-map").hide();
               $("#vehicle-list_button").button('toggle');
        },
    
		//START:Tower Administrator click handler functions
		ta_new_vehicle_clickHandler:function()
		{ 
		 $("#page-status-count").html('');
		 $("#pagePanel").hide();
			 if(current_page==AppConstants.VEHICLE_LIST)
			  {     
				   //this.setVehicle_List();
				   $('li').removeClass('active').addClass('inactive');
				   $('#ta-new-vehicle-component').removeClass('inactive').addClass('active');  
		   
					this.dispatchEvent( HomePage.STATUS_TOW_NEW_VEHICLE);
				  
			  }
			  else
			   {
				   //window.location='vehicle_list.php?tab=1';
			   }   
					
		},
                
		ta_progress_clickHandler:function()
		{ 
		   
		$("#pagePanel").hide();
		$("#page-status-count").html('');
			 if(current_page==AppConstants.VEHICLE_LIST)
			  {   
				   //this.setVehicle_List();
				   $('li').removeClass('active').addClass('inactive');
				   $('#ta-progress-vehicle-component').removeClass('inactive').addClass('active');  
		   
					this.dispatchEvent( HomePage.STATUS_TOW_INPROGRESS_VEHICLE );
				   
			  }
			  else
			   {
				   //window.location='vehicle_list.php?tab=1';
			   }   
					
		},
		ta_delivered_clickHandler:function()
		{ 
		   
		$("#pagePanel").hide();
		$("#page-status-count").html('');
			 if(current_page==AppConstants.VEHICLE_LIST)
			  {   
				   //this.setVehicle_List();
				   $('li').removeClass('active').addClass('inactive');
				   $('#ta-delivered-vehicle-component').removeClass('inactive').addClass('active');  
		   
					this.dispatchEvent( HomePage.STATUS_TOW_DELIVERED_VEHICLE );
				   
			  }
			  else
			   {
				   //window.location='vehicle_list.php?tab=1';
			   }   
					
		},
		ta_all_vehicle_clickHandler:function()
		{ 
		   
		$("#pagePanel").hide();
			$("#page-status-count").html('');
			 if(current_page==AppConstants.VEHICLE_LIST)
			  {   
				   //this.setVehicle_List();
				   $('li').removeClass('active').addClass('inactive');
				   $('#ta-all-vehicle-component').removeClass('inactive').addClass('active');  
		   
                                            this.dispatchEvent( HomePage.STATUS_TOW_ALL_VEHICLE );
				   
			  }
			  else
			   {
				   //window.location='vehicle_list.php?tab=1';
			   }   
					
		},
		//END:Tower Administrator click handler functions
                
                
         towernewvehicles_clickHandler: function()
      {
      	
          window.location='vehicle_list.php?tab=1';
          $("#pagePanel").hide();
      },
      
      towerinprogressvehicles_clickHandler: function()
      {
          window.location='vehicle_list.php?tab=2';
          
      },
      
      towerdeliveredvehicles_clickHandler: function()
      {
          window.location='vehicle_list.php?tab=3';
      },
        towerallvehicles_clickHandler: function()
      {
          window.location='vehicle_list.php?tab=4';
      },       
		
	newSubmission_clickHandler: function()
	{ 
	   
    
         if(current_page==AppConstants.VEHICLE_LIST)
          {   
               this.setVehicle_List();
               $('li').removeClass('active').addClass('inactive');
               $('#new-vehicle-component').removeClass('inactive').addClass('active');  
       
                this.dispatchEvent( HomePage.STATUS_NEW_SUBMISSION );
               
          }
          else
           {
               window.location='vehicle_list.php?tab=1';
           }   
                
	},
	bidAccepted_clickHandler: function()
	{ 
	  
          if(current_page==AppConstants.VEHICLE_LIST)
          {    
               this.setVehicle_List();   
               $('li').removeClass('active').addClass('inactive');
               $('#bidaccepted-vehicle-component').removeClass('inactive').addClass('active');     
               this.dispatchEvent( HomePage.STATUS_BID_ACCEPTED );   
          
          }
          else
          {
                  window.location='vehicle_list.php?tab=2';
          }
                
	},
	inPossession_clickHandler: function()
	{ 
           if(current_page==AppConstants.VEHICLE_LIST)
           {    
              this.setVehicle_List();    
              $('li').removeClass('active').addClass('inactive');
              $('#inpossesion-vehicle-component').removeClass('inactive').addClass('active');  
              this.dispatchEvent( HomePage.STATUS_IN_POSSEESSION );
           }
           else
           {
              window.location='vehicle_list.php?tab=3';     
           }
                
	},
	allVehicle_clickHandler: function()
	{ 
            
             if(current_page==AppConstants.VEHICLE_LIST)
           {    
              this.setVehicle_List();    
              $('li').removeClass('active').addClass('inactive');
              $('#all-vehicle-component').removeClass('inactive').addClass('active');
               this.dispatchEvent( HomePage.STATUS_ALL_VEHICLE )      
           }
           else
           {
              window.location='vehicle_list.php?tab=4';     
           }
	  
	},
	addNewVehicle_clickHandler: function()
	{ 
                $("#dash-board-component").hide();
                $("#vehicle-list-page").hide();
		//$("#vehicle-tabs").hide();
                $("#vehicle-content-info").show();
		$("#info-tabs").show();
		//$("#v-control-panel").hide();
                // $("#page-map").hide();
		//$("#v-info-control-bar").show();
		//$("#vehicle-list-header").css({'visibility':'collapse'});	
                 $('li').removeClass('active').addClass('inactive');
                 $('#ainfo-li').removeClass('inactive').addClass('active');    
		this.dispatchEvent(HomePage.ADD_NEW_VEHICLE);
	},
	vehicleList_clickHandler: function()
	{ 
              //  $("#content").children().hide();
               // $("#dash-board-component").hide();
               // $("#vehicle-list-component").show();
                
		/*$('div.page-map').hide();
		var number = $(this).index();
		$('div.page-list').slideUp(400).eq(number).slideDown(400);
		$('div.page-list').show();
	   	this.dispatchEvent( HomePage.VEHICLE_LIST_VIEW );*/
             
             
	},
        vehicleListArea_clickHandler: function()
        {
              $("#vehicle-list-component").show();
              $("#page-map").hide();
              $("#vehicle-list_button").button('toggle');
        },
        
	vehicleMap_clickHandler: function()
	{
              
              $("#vehicle-list-component").hide();
             // $("#page-panel").hide();
          
		
		var number = $(this).index();
		$('#vehicle-list-header').css({"display":"none"});
		$('#v-scroll-header').css({"display":"none"});
		$('div.page-map').slideUp(400).eq(number).slideDown(400);
		$('div.page-map').show();
		$('div.page-map').css({"visibility":"visible"});	
		google.maps.event.trigger(listmap, 'resize');	
	    this.dispatchEvent( HomePage.VEHICLE_MAP_VIEW );
	},
	vehicleRefresh_clickHandler: function()
	{ 
	  this.dispatchEvent( HomePage.VEHICLE_REFRESH );
	}

});
HomePage.STATUS_TOW_NEW_VEHICLE="statusTowNewVehicle";
HomePage.STATUS_TOW_INPROGRESS_VEHICLE="statusTowInprogressVehicle";
HomePage.STATUS_TOW_DELIVERED_VEHICLE="statusTowDeliveredVehicle";
HomePage.STATUS_TOW_ALL_VEHICLE="statusTowAllVehicle";



HomePage.SIGNOUT ="signOut";
HomePage.SHOW_PROFILE ="showProfile";
HomePage.DO_RESTORE ="doRestore";
//HomePage.VIEW_DASHBOARD ="viewDashboard";

HomePage.STATUS_NEW_SUBMISSION ="statusNewSubmission";
HomePage.STATUS_BID_ACCEPTED ="statusBidAccepted";
HomePage.STATUS_IN_POSSEESSION ="statusInPossession";
HomePage.STATUS_ALL_VEHICLE ="statusAllVehicle";

HomePage.ADD_NEW_VEHICLE ="addNewVehicle";
HomePage.VEHICLE_LIST_VIEW ="vehicleListView";
HomePage.VEHICLE_MAP_VIEW ="vehicleMapView";
HomePage.VEHICLE_REFRESH ="vehicleRefresh";



HomePage.LOCKED_VEHICLE ="lockedVehicle";

HomePage.SORT_VID ="sortVehicleId";
HomePage.SORT_YEAR ="sortYear";
HomePage.SORT_MAKE ="sortMake";
HomePage.SORT_MODEL ="sortModel";
HomePage.SORT_SELER ="sortSeller";
HomePage.SORT_CITY_STATE ="sortCityState";
HomePage.SORT_UPDATE_DATE ="sortUpdateDate";
HomePage.SORT_PRICE ="sortPrice";
HomePage.SORT_ASSIST_BY ="sortAssist";
HomePage.SORT_ACTION ="sortAction";
HomePage.SORT_WATCHLIST ="sortWatchList";
HomePage.SORT_MESSAGE="sortMessage";

HomePage.SEARCH="search";
